package com.colin.project.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import java.sql.Timestamp;

@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)//链式调用

public class Video {
    private Integer id;
    private User user;
    private Timestamp uploadTime;
    private String originalPath;
    private String mappingPath;
    private String videoType;
    private String videoSize;
    private String originalName;


    /**
     * 使用构建者模式
     * @param videoBuilder
     */
    private Video(VideoBuilder videoBuilder) {
        this.id = videoBuilder.id;
        this.user = videoBuilder.user;
        this.uploadTime = videoBuilder.uploadTime;
        this.originalPath = videoBuilder.originalPath;
        this.mappingPath = videoBuilder.mappingPath;
        this.videoType = videoBuilder.videoType;
        this.videoSize = videoBuilder.videoSize;
        this.originalName = videoBuilder.originalName;
    }

    /**
     * 构建者对象
     */
    public static class VideoBuilder {
        private Integer id;
        private User user;
        private Timestamp uploadTime;
        private String originalPath;
        private String mappingPath;
        private String videoType;
        private String videoSize;
        private String originalName;

        public VideoBuilder id(Integer id) {
            this.id = id;
            return this;
        }

        public VideoBuilder user(User user) {
            this.user = user;
            return this;
        }

        public VideoBuilder uploadTime(Timestamp uploadTime) {
            this.uploadTime = uploadTime;
            return this;
        }

        public VideoBuilder originalPath(String originalPath) {
            this.originalPath = originalPath;
            return this;
        }

        public VideoBuilder mappingPath(String mappingPath) {
            this.mappingPath = mappingPath;
            return this;
        }

        public VideoBuilder videoType(String videoType) {
            this.videoType = videoType;
            return this;
        }

        public VideoBuilder videoSize(String videoSize) {
            this.videoSize = videoSize;
            return this;
        }

        public VideoBuilder originalName(String originalName) {
            this.originalName = originalName;
            return this;
        }

        public Video build() {
            return new Video(this);
        }
    }
}
